package lab02.test17;

public class Test17 {
    public static void main(String[] args) {

        int[] numbers = new int[10];

        numbers[0] = 10;
        numbers[1] = 36;
        numbers[2] = 19;
        numbers[3] = 60;
        numbers[4] = 27;
        numbers[5] = 13;
        numbers[6] = 52;
        numbers[7] = 33;
        numbers[8] = 26;
        numbers[9] = 15;

        max(numbers);
        min(numbers);

        int sum = 0;
        for(int i = 0;i < numbers.length ; i++) {
            sum = sum + numbers[i];
        }

        System.out.println("sum = " + sum);
    }

    public static void max(int[] numbers) {
        int max = 0;
        int k = 0;
        for(int i = 0;i < numbers.length;i++) {
            if (numbers[i] > max) {
                max = numbers[i];
                k = i;
            }
        }
        System.out.println("max = " + max + "\n" + "是第" + (k+1) + "个数");
    }

    public static void min(int[] numbers) {
        int min = numbers[0];
        int k = 0;
        for(int i = 0;i < numbers.length;i++) {
            if (numbers[i] < min) {
                min = numbers[i];
                k = i;
            }
        }
        System.out.println("min = " + min + "\n" + "是第" + (k+1) + "个数");
    }
}
